Soru & Cevap

Arkadaşlar bu hatayı alıyorum. Lütfen yardım edin

31.01.2019 - 04:02
@Entity(tableName = PLAYLIST_STREAM_JOIN_TABLE,
        primaryKeys = {JOIN_PLAYLIST_ID, JOIN_INDEX},
        indices = {
                @Index(value = {JOIN_PLAYLIST_ID, JOIN_INDEX}, unique = true),
                @Index(value = {JOIN_STREAM_ID})
        },
        foreignKeys = {
                @ForeignKey(entity = PlaylistEntity.class,
                        parentColumns = PlaylistEntity.PLAYLIST_ID,
                        childColumns = JOIN_PLAYLIST_ID,
                        onDelete = CASCADE, onUpdate = CASCADE, deferred = true),
                @ForeignKey(entity = StreamEntity.class,
                        parentColumns = StreamEntity.STREAM_ID,
                        childColumns = JOIN_STREAM_ID,
                        onDelete = CASCADE, onUpdate = CASCADE, deferred = true)
        })
public class PlaylistStreamEntity {

    final public static String PLAYLIST_STREAM_JOIN_TABLE   = "playlist_stream_join";
    final public static String JOIN_PLAYLIST_ID             = "playlist_id";
    final public static String JOIN_STREAM_ID               = "stream_id";
    final public static String JOIN_INDEX                   = "join_index";

    @ColumnInfo(name = JOIN_PLAYLIST_ID)
    private long playlistUid;

    @ColumnInfo(name = JOIN_STREAM_ID)
    private long streamUid;

    @ColumnInfo(name = JOIN_INDEX)
    private int Index;

    public PlaylistStreamEntity(final long playlistUid, final long streamUid, final int index) {
        this.playlistUid = playlistUid;
        this.streamUid = streamUid;
        this.Index = index;
    }

    public long getPlaylistUid() {
        return playlistUid;
    }

    public long getStreamUid() {
        return streamUid;
    }

    public int getIndex() {
        return Index;
    }

    public void setPlaylistUid(long playlistUid) {
        this.playlistUid = playlistUid;
    }

    public void setStreamUid(long streamUid) {
        this.streamUid = streamUid;
    }

    public void setIndex(int index) {
        this.Index = index;
    }
}

 

 

 

HATA error: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).
Tried the following constructors but they failed to match:
PlaylistStreamEntity(long,long,int) -> [param:playlistUid -> matched field:playlistUid, param:streamUid -> matched field:streamUid, param:index -> matched field:unmatched]

 

58 Görüntülenme

2 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user petabyte64
petabyte64
04.01.2024 - 03:23
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;

import static androidx.room.ForeignKey.CASCADE;

@Entity(
        tableName = PlaylistStreamEntity.PLAYLIST_STREAM_JOIN_TABLE,
        primaryKeys = {PlaylistStreamEntity.JOIN_PLAYLIST_ID, PlaylistStreamEntity.JOIN_INDEX},
        indices = {
                @Index(value = {PlaylistStreamEntity.JOIN_PLAYLIST_ID, PlaylistStreamEntity.JOIN_INDEX}, unique = true),
                @Index(value = {PlaylistStreamEntity.JOIN_STREAM_ID})
        },
        foreignKeys = {
                @ForeignKey(
                        entity = PlaylistEntity.class,
                        parentColumns = PlaylistEntity.PLAYLIST_ID,
                        childColumns = PlaylistStreamEntity.JOIN_PLAYLIST_ID,
                        onDelete = CASCADE, onUpdate = CASCADE, deferred = true
                ),
                @ForeignKey(
                        entity = StreamEntity.class,
                        parentColumns = StreamEntity.STREAM_ID,
                        childColumns = PlaylistStreamEntity.JOIN_STREAM_ID,
                        onDelete = CASCADE, onUpdate = CASCADE, deferred = true
                )
        }
)
public class PlaylistStreamEntity {

    final public static String PLAYLIST_STREAM_JOIN_TABLE = "playlist_stream_join";
    final public static String JOIN_PLAYLIST_ID = "playlist_id";
    final public static String JOIN_STREAM_ID = "stream_id";
    final public static String JOIN_INDEX = "join_index";

    @ColumnInfo(name = JOIN_PLAYLIST_ID)
    private long playlistUid;

    @ColumnInfo(name = JOIN_STREAM_ID)
    private long streamUid;

    @ColumnInfo(name = JOIN_INDEX)
    private int joinIndex;

    public PlaylistStreamEntity(long playlistUid, long streamUid, int joinIndex) {
        this.playlistUid = playlistUid;
        this.streamUid = streamUid;
        this.joinIndex = joinIndex;
    }

    public long getPlaylistUid() {
        return playlistUid;
    }

    public long getStreamUid() {
        return streamUid;
    }

    public int getJoinIndex() {
        return joinIndex;
    }

    public void setPlaylistUid(long playlistUid) {
        this.playlistUid = playlistUid;
    }

    public void setStreamUid(long streamUid) {
        this.streamUid = streamUid;
    }

    public void setJoinIndex(int joinIndex) {
        this.joinIndex = joinIndex;
    }
}

 

Profile picture for user furkankaplan
furkankaplan
29.09.2019 - 05:16
Hata mesajının anlamı şu, her entity bir boş constructer a sahip olmalıdır. Sizin boş constructer varsa bile private ya da boş constructer ınız yok diyor. Bunun için public constructer ını kodunuza eklerseniz sorun çözülür. Kolay gelsin